package org.example.call.controller;

import org.example.call.domain.SmbmsBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class RestTemplateController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/callByRestTemplate/{id}")
    public SmbmsBill callByRestTemplate(@PathVariable("id") Long id) {
        String url = "http://mybatis-service/api/" + id;
        return restTemplate.getForObject(url, SmbmsBill.class);
    }
}
